<!DOCTYPE html>
<html  lang="en">
<head>
    <meta charset="utf-8">
<title>httpd服务 - noback</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />



    <meta name="description" content="apache http serverApache HTTP Server（简称Apache）是Apache软件基金会的一个开放源码的网页服务器，可以在大多数计算机操作系统中运行，由于其多平台和安全性被广泛使用，是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展，将Perl&#x2F;Python等解释器编译到服务器中。   在Apache中，其配置文件目录为“&#x2F;etc&#x2F;httpd&#x2F;co">
<meta property="og:type" content="article">
<meta property="og:title" content="httpd服务">
<meta property="og:url" content="http://alpaca-h.gitee.io/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/index.html">
<meta property="og:site_name" content="noback">
<meta property="og:description" content="apache http serverApache HTTP Server（简称Apache）是Apache软件基金会的一个开放源码的网页服务器，可以在大多数计算机操作系统中运行，由于其多平台和安全性被广泛使用，是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展，将Perl&#x2F;Python等解释器编译到服务器中。   在Apache中，其配置文件目录为“&#x2F;etc&#x2F;httpd&#x2F;co">
<meta property="og:locale" content="en_US">
<meta property="og:image" content="http://alpaca-h.gitee.io/images/og_image.png">
<meta property="article:published_time" content="2020-01-03T09:18:50.000Z">
<meta property="article:modified_time" content="2020-01-05T05:09:20.328Z">
<meta property="article:author" content="Alpaca">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://alpaca-h.gitee.io/images/og_image.png">







<link rel="icon" href="/images/favicon.svg">


<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.7.2/css/bulma.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.4.1/css/all.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,600|Source+Code+Pro">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/highlight.js@9.12.0/styles/androidstudio.css">


    
    
    
    <style>body>.footer,body>.navbar,body>.section{opacity:0}</style>
    

    
    
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
    

    
    

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">


    
    
    
    

<link rel="stylesheet" href="/css/back-to-top.css">


    
    

    
    
    
    

    
    
<link rel="stylesheet" href="/css/progressbar.css">
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

    
    
    

    
    
    
        <script async="" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    

    


<link rel="stylesheet" href="/css/style.css">
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="noback" type="application/atom+xml">
</head>
<body class="is-3-column">
    <nav class="navbar navbar-main">
    <div class="container">
        <div class="navbar-brand is-flex-center">
            <a class="navbar-item navbar-logo" href="/">
            
                <img src="/images/logo.svg" alt="httpd服务" height="28">
            
            </a>
        </div>
        <div class="navbar-menu">
            
            <div class="navbar-start">
                
                <a class="navbar-item"
                href="/">Home</a>
                
                <a class="navbar-item"
                href="/archives/">Archives</a>
                
                <a class="navbar-item"
                href="/categories/">Categories</a>
                
                <a class="navbar-item"
                href="/tags/">Tags</a>
                
                <a class="navbar-item"
                href="/about/">About</a>
                
            </div>
            
            <div class="navbar-end">
                
                    
                    
                    <a class="navbar-item" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>
                        
                    </a>
                    
                
                
                <a class="navbar-item is-hidden-tablet catalogue" title="Catalogue" href="javascript:;">
                    <i class="fas fa-list-ul"></i>
                </a>
                
                
                <a class="navbar-item search" title="Search" href="javascript:;">
                    <i class="fas fa-search"></i>
                </a>
                
            </div>
        </div>
    </div>
</nav>
    
    <section class="section">
        <div class="container">
            <div class="columns">
                <div class="column is-8-tablet is-8-desktop is-9-widescreen has-order-2 column-main"><div class="card">
    
    <div class="card-content article ">
        <h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
            
                <i class="fas fa-angle-double-right"></i>httpd服务
            
        </h1>
        
        <div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
            <div class="level-left">
                <time class="level-item has-text-grey" datetime="2020-01-03T09:18:50.000Z"><i class="far fa-calendar-alt">&nbsp;</i>2020-01-03</time>
                
                <time class="level-item has-text-grey is-hidden-mobile" datetime="2020-01-05T05:09:20.328Z"><i class="far fa-calendar-check">&nbsp;</i>2020-01-05</time>
                
                
                <div class="level-item">
                <i class="far fa-folder-open has-text-grey"></i>&nbsp;
                <a class="has-link-grey -link" href="/categories/blog-back-new/">blog_back_new</a>&nbsp;/&nbsp;<a class="has-link-grey -link" href="/categories/blog-back-new/linux/">linux</a>
                </div>
                
                
                <span class="level-item has-text-grey">
                    <i class="far fa-clock"></i>&nbsp;
                    
                    
                    5 minutes read (About 741 words)
                </span>
                
                
                <span class="level-item has-text-grey" id="busuanzi_container_page_pv">
                    <i class="far fa-eye"></i>
                    <span id="busuanzi_value_page_pv">0</span> visits
                </span>
                
            </div>
        </div>
        
        <div class="content">
            <h2 id="apache-http-server"><a href="#apache-http-server" class="headerlink" title="apache http server"></a>apache http server</h2><p>Apache HTTP Server（简称Apache）是Apache软件基金会的一个开放源码的网页服务器，可以在大多数计算机操作系统中运行，由于其多平台和安全性被广泛使用，是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展，将Perl/Python等解释器编译到服务器中。</p>
<p><font color='blue'>  在Apache中，其配置文件目录为“/etc/httpd/conf/httpd.conf”，这里面包括设置网站资源的存放目录及一些相关的配置。</font></p>
<pre><code class="bash"># 安装http
yum install httpd 
# 开启服务
systemctl start httpd
# 检查httpd服务状态
systemctl status httpd
# 查看端口状态 netstat -anutp | grep  80</code></pre>
<h3 id="目录介绍"><a href="#目录介绍" class="headerlink" title="目录介绍"></a>目录介绍</h3><p>配置文件目录为“/etc/httpd/conf/httpd.conf”</p>
<pre><code class="bash">[root@localhost httpd]# ls -1
conf  # 存放服务的主配置文件
conf.d # 存放apache的主页信息
conf.modules.d
logs
modules
run</code></pre>
<h3 id="配置信息"><a href="#配置信息" class="headerlink" title="配置信息"></a>配置信息</h3><p>配置文件目录为“/etc/httpd/conf/httpd.conf”</p>
<pre><code class="bash">[root@localhost httpd]# vi /etc/httpd/conf/httpd.conf
ServerRoot &quot;/etc/httpd&quot;  #apache配置文件的根目录
Timeout 60  #超时时间，即连接服务端在60秒内没有任何操作，即自动断开
Listen 80   #监听的端口
ServerAdmin root@localhost  #设置管理员，e-mail 地址
ServerName www.example.com:80  #服务器主机名.

DocumentRoot &quot;/var/www/html&quot;   #网站页面根目录,存放文档的地方
&lt;Directory &quot;/var/www/html&quot;&gt; 
Options Indexes FollowSymLinks #O目录浏览 #Followsymlinks:可以用连接，要是想要禁止显示文件目录，可以直接在‘indexes’前加‘-’。
    AllowOverride None
    Order allow,deny #目录与访问的控制
    Allow from all 
&lt;/Directory&gt;

# 别名
Alias /icons/ &quot;/var/www/icons/&quot; #别名和别名目录
&lt;Directory &quot;/var/www/icons&quot;&gt;
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
&lt;/Directory&gt;

# 默认页面
&lt;/Directory&gt; Options Indexes  #当一个目录没有默认首页时，允许显示此目录列表
&lt;Directory /&gt;
    Options FollowSymLinks
    AllowOverride None
&lt;/Directory&gt;
--
DirectoryIndex index.html index.html.var #指定默认首页
AddDefaultCharset UTF-8   #设置服务器的默认编码为： UTF-8</code></pre>
<h2 id="python3构建http服务"><a href="#python3构建http服务" class="headerlink" title="python3构建http服务"></a>python3构建http服务</h2><pre><code class="bash">python3 -m http.server </code></pre>
<h2 id="维护-amp-错误"><a href="#维护-amp-错误" class="headerlink" title="维护&amp;错误"></a>维护&amp;错误</h2><h3 id="http服务已开启，但是无法访问网站"><a href="#http服务已开启，但是无法访问网站" class="headerlink" title="http服务已开启，但是无法访问网站"></a>http服务已开启，但是无法访问网站</h3><ol>
<li>在本地查看httpd服务<pre><code class="bash">curl http://localhost:80  </code></pre>
</li>
<li>看端口，如果是在公司内部，查看是否有部分ip端口被封 比如80 8080 88 等等<br>如果是以上情况，修改httpd 配置文件中的监听端口，重启http服务即可</li>
<li>永久关闭selinux ,需要重启<pre><code class="bash">vi /etc/selinux/config
SELINUX=disabled</code></pre>
</li>
<li>临时关闭<pre><code class="bash">setenforce 0 </code></pre>
</li>
</ol>
<p>可能会出现的报错信息<br>(13)Permission denied: make_sock: could not bind to address [::]:88<br>—-&gt; 关闭selinux即可</p>
<h3 id="检测端口是否被开启"><a href="#检测端口是否被开启" class="headerlink" title="检测端口是否被开启"></a>检测端口是否被开启</h3><p>使用telnet登陆的方式测试服务器端口是否开放</p>
<pre><code class="bash"># 未开放状态下的返回情况
➜  ~ telnet 10.0.5.92 8888
Trying 10.0.5.92...
telnet: Unable to connect to remote host: Connection refused

# 开放状态下的返回情况
➜  ~ telnet 10.0.5.91 8888
Trying 10.0.5.91...
Connected to 10.0.5.91.
Escape character is &#39;^]&#39;.</code></pre>
<h3 id="开放端口"><a href="#开放端口" class="headerlink" title="开放端口"></a>开放端口</h3><p>端口未被开放<br>———&gt; iptables -I INPUT -p tcp –dport 8888 -j ACCEPT</p>
<h2 id="地址"><a href="#地址" class="headerlink" title="地址"></a>地址</h2><p><a href="https://www.linuxidc.com/Linux/2017-05/143468.htm" target="_blank" rel="noopener">https://www.linuxidc.com/Linux/2017-05/143468.htm</a></p>

        </div>
        
            <ul class="post-copyright">
            <li><strong>本文标题：</strong><a href="http://alpaca-h.gitee.io/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/">httpd服务</a></li>
            <li><strong>本文作者：</strong><a href="http://alpaca-h.gitee.io">Alpaca</a></li>
            <li><strong>本文链接：</strong><a href="http://alpaca-h.gitee.io/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/">http://alpaca-h.gitee.io/2020/01/03/blog_back_new/linux/httpd%E6%9C%8D%E5%8A%A1/</a></li>
            <li><strong>发布时间：</strong>2020-01-03</li>
            <li><strong>版权声明：</strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="external nofollow" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处！
            </li>
            </ul>
        
        
        
        
    </div>
</div>





<div class="card card-transparent">
    <div class="level post-navigation is-flex-wrap is-mobile">
        
        <div class="level-start">
            <a class="level level-item has-link-grey  article-nav-prev" href="/2020/01/04/blog_back_new/%E7%BD%91%E7%BB%9C/%E7%BD%91%E7%BB%9C%E9%83%A8%E7%BD%B2%E9%9C%80%E6%B1%82%E5%88%86%E6%9E%90/">
                <i class="level-item fas fa-chevron-left"></i>
                <span class="level-item">网络部署需求分析</span>
            </a>
        </div>
        
        
        <div class="level-end">
            <a class="level level-item has-link-grey  article-nav-next" href="/2020/01/03/blog_back_new/%E7%BD%91%E7%BB%9C/%E4%BA%A4%E6%8D%A2%E6%9C%BA%E6%A3%80%E6%B5%8B%E4%BF%A1%E6%81%AF/">
                <span class="level-item">交换机检测命令</span>
                <i class="level-item fas fa-chevron-right"></i>
            </a>
        </div>
        
    </div>
</div>



</div>
                




<div class="column is-4-tablet is-4-desktop is-3-widescreen  has-order-1 column-left ">
    
        
<div class="card widget">
    <div class="card-content">
        <nav class="level" style="margin-bottom:1rem">
            <div class="level-item has-text-centered">
                <div>
                    
                        <img class="image is-96x96 has-mb-6" src="https://www.gravatar.com/avatar/e0f4032c0f2d1068ffffbaf93c0bef52?s=96" alt="Xinyu Liu">
                    
                    
                    <p class="is-size-4 is-block">
                        Xinyu Liu
                    </p>
                    
                    
                    <p class="is-size-6 is-block">
                        Alpha Lxy
                    </p>
                    
                    
                    <p class="is-size-6 is-flex is-flex-center has-text-grey">
                        <i class="fas fa-map-marker-alt has-mr-7"></i>
                        <span>Beijing, China</span>
                    </p>
                    
                </div>
            </div>
        </nav>
        <nav class="level menu-list is-mobile" style="margin-bottom:1rem">
            <div class="level-item has-text-centered is-marginless">
                <a href="/archives/">
                    <p class="heading">
                        Posts
                    </p>
                    <p class="title has-text-weight-normal">
                        40
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/categories/">
                    <p class="heading">
                        Categories
                    </p>
                    <p class="title has-text-weight-normal">
                        13
                    </p>
                </a>
            </div>
            <div class="level-item has-text-centered is-marginless">
                <a href="/tags/">
                    <p class="heading">
                        Tags
                    </p>
                    <p class="title has-text-weight-normal">
                        0
                    </p>
                </a>
            </div>
        </nav>
        <div class="level">
            <a class="level-item button is-link is-rounded" href="https://www.github.com/AlphaLxy" target="_blank">
                <i class="fab fa-github"></i>&nbsp;&nbsp;Follow</a>
        </div>
        
        
    </div>
</div>

    
        
<div class="card widget column-left is-sticky" id="toc">
    <div class="card-content">
        <div class="menu">
            <h3 class="menu-label">
                Catalogue
            </h3>
            <ul class="menu-list"><li>
        <a class="is-flex" href="#apache-http-server">
        <span class="has-mr-6">1</span>
        <span>apache http server</span>
        </a><ul class="menu-list"><li>
        <a class="is-flex" href="#目录介绍">
        <span class="has-mr-6">1.1</span>
        <span>目录介绍</span>
        </a></li><li>
        <a class="is-flex" href="#配置信息">
        <span class="has-mr-6">1.2</span>
        <span>配置信息</span>
        </a></li></ul></li><li>
        <a class="is-flex" href="#python3构建http服务">
        <span class="has-mr-6">2</span>
        <span>python3构建http服务</span>
        </a></li><li>
        <a class="is-flex" href="#维护-amp-错误">
        <span class="has-mr-6">3</span>
        <span>维护&错误</span>
        </a><ul class="menu-list"><li>
        <a class="is-flex" href="#http服务已开启，但是无法访问网站">
        <span class="has-mr-6">3.1</span>
        <span>http服务已开启，但是无法访问网站</span>
        </a></li><li>
        <a class="is-flex" href="#检测端口是否被开启">
        <span class="has-mr-6">3.2</span>
        <span>检测端口是否被开启</span>
        </a></li><li>
        <a class="is-flex" href="#开放端口">
        <span class="has-mr-6">3.3</span>
        <span>开放端口</span>
        </a></li></ul></li><li>
        <a class="is-flex" href="#地址">
        <span class="has-mr-6">4</span>
        <span>地址</span>
        </a></li></ul>
        </div>
    </div>
</div>


    
    
        <div class="column-right-shadow is-hidden-widescreen ">
        
        </div>
    
</div>

                
            </div>
        </div>
    </section>
    <footer class="footer">
    <div class="container">
        <div class="level">
            <div class="level-start has-text-centered-mobile">
                <a class="footer-logo is-block has-mb-6" href="/">
                
                    <img src="/images/logo.svg" alt="httpd服务" height="28">
                
                </a>
                <p class="is-size-7">
                &copy; 2020 Alpaca&nbsp;
                Powered by <a href="http://hexo.io/" target="_blank">Hexo</a> & <a
                        href="http://github.com/ppoffice/hexo-theme-icarus" target="_blank">Icarus</a>
                
                <br>
                <span id="busuanzi_container_site_uv">
                Visited by <span id="busuanzi_value_site_uv">0</span> users
                </span>
                
                </p>
            </div>
            <div class="level-end">
            
                <div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">
                
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="CC BY-NC-SA 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/">
                        
                        <i class="fab fa-creative-commons"></i>&nbsp;<i class="fab fa-creative-commons-by"></i>&nbsp;<i class="fab fa-creative-commons-nc"></i>&nbsp;<i class="fab fa-creative-commons-sa"></i>&nbsp;
                        
                    </a>
                </p>
                
                <p class="control">
                    <a class="button is-white is-large" target="_blank" title="AlphaLxy GitHub" href="https://www.github.com/AlphaLxy">
                        
                        <i class="fab fa-github"></i>&nbsp;
                        
                    </a>
                </p>
                
                </div>
            
            </div>
        </div>
    </div>
</footer>

    <script src="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/min/moment-with-locales.min.js"></script>
<script>moment.locale("en");</script>


    
    
    
    <script src="/js/animation.js"></script>
    

    
    
    
    <script src="https://cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/js/lightgallery.min.js" defer></script>
    <script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js" defer></script>
    <script src="/js/gallery.js" defer></script>
    

    
    

<div id="outdated">
    <h6>Your browser is out-of-date!</h6>
    <p>Update your browser to view this website correctly. <a id="btnUpdateBrowser" href="http://outdatedbrowser.com/" target="_blank" rel="noopener">Update
            my browser now </a></p>
    <p class="last"><a href="#" id="btnCloseUpdateBrowser" title="Close">&times;</a></p>
</div>
<script src="https://cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.js" defer></script>
<script>
    document.addEventListener("DOMContentLoaded", function () {
        outdatedBrowser({
            bgColor: '#f25648',
            color: '#ffffff',
            lowerThan: 'flex'
        });
    });
</script>


    
    
<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.5/unpacked/MathJax.js?config=TeX-MML-AM_CHTML" defer></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    MathJax.Hub.Config({
        'HTML-CSS': {
            matchFontHeight: false
        },
        SVG: {
            matchFontHeight: false
        },
        CommonHTML: {
            matchFontHeight: false
        },
        tex2jax: {
            inlineMath: [
                ['$','$'],
                ['\\(','\\)']
            ]
        }
    });
});
</script>

    
    

<a id="back-to-top" title="Back to Top" href="javascript:;">
    <i class="fas fa-chevron-up"></i>
</a>
<script src="/js/back-to-top.js" defer></script>


    
    

    
    
    
    

    
    
    
    
    
    <script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.4/dist/clipboard.min.js" defer></script>
    <script src="/js/clipboard.js" defer></script>
    

    
    
    

    


<script src="/js/main.js" defer></script>

    
    <div class="searchbox ins-search">
    <div class="searchbox-container ins-search-container">
        <div class="searchbox-input-wrapper">
            <input type="text" class="searchbox-input ins-search-input" placeholder="Type something..." />
            <span class="searchbox-close ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="searchbox-result-wrapper ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
    (function (window) {
        var INSIGHT_CONFIG = {
            TRANSLATION: {
                POSTS: 'Posts',
                PAGES: 'Pages',
                CATEGORIES: 'Categories',
                TAGS: 'Tags',
                UNTITLED: '(Untitled)',
            },
            CONTENT_URL: '/content.json',
        };
        window.INSIGHT_CONFIG = INSIGHT_CONFIG;
    })(window);
</script>
<script src="/js/insight.js" defer></script>
<link rel="stylesheet" href="/css/search.css">
<link rel="stylesheet" href="/css/insight.css">
    
</body>
</html>